import pytest
import requests
from 接口自动化.case.DButils import *
from 接口自动化.send.Send import Send
from 接口自动化.utils.read_yaml import read_yaml
class TestFund:

    @pytest.mark.parametrize( "args" , read_yaml("../data/pocketmoney.yaml"))
    def test_pocketmoney(self,args):

        name = args["username"]
        pwd= args["pwd"]
        session  = requests.session()

        se = Send()
        login = se.send_login(session,name,pwd)
        print(login["body"]["code"])

        changeMoneyId = args["changeMoneyId"]
        userId= args["userId"]
        passWord = args["passWord"]
        exp = args["exp"]
        result = se.send_pocketmoney(session,changeMoneyId,userId,passWord)

        assert result["code"] == 200 and result["body"]["code"] == exp
        #
        # sql = "update user set password= %s where username  = %s"
        # param = ["e10adc3949ba59abbe56e057f20f883e","lisi"]
        # update(sql, param)
    @pytest.mark.parametrize( "args" , read_yaml("../data/termmoney.yaml"))
    def test_termmoney(self,args):

        name = args["username"]
        pwd= args["pwd"]
        session  = requests.session()
        se = Send()
        login = se.send_login(session,name,pwd)
        print(login["body"]["code"])

        termFinancialId = args["termFinancialId"]
        userId= args["userId"]
        passWord = args["passWord"]
        exp = args["exp"]
        result = se.send_pocketmoney(session,termFinancialId,userId,passWord)

        assert result["code"] == 200 and result["body"]["code"] == exp
        #
        # sql = "update user set password= %s where username  = %s"
        # param = ["e10adc3949ba59abbe56e057f20f883e","lisi"]
        # update(sql, param)
    @pytest.mark.parametrize( "args" , read_yaml("../data/fundmoney.yaml"))
    def test_fundmoney(self,args):

        name = args["username"]
        pwd= args["pwd"]
        session  = requests.session()
        se = Send()
        login = se.send_login(session,name,pwd)
        print(login["body"]["code"])

        fundProductId = args["fundProductId"]
        userId= args["userId"]
        passWord = args["passWord"]
        exp = args["exp"]
        result = se.send_fundmoney(session,fundProductId,userId,passWord)

        assert result["code"] == 200 and result["body"]["code"] == exp
        #
        # sql = "update user set password= %s where username  = %s"
        # param = ["e10adc3949ba59abbe56e057f20f883e","lisi"]
        # update(sql, param)